@echo off

rem lambda-tube (?-tube) - A youtube search API and application in scheme.
rem Copyright (C) 2008 Abhishek Mishra
rem
rem This program is free software: you can redistribute it and/or modify
rem it under the terms of the GNU General Public License as published by
rem the Free Software Foundation, either version 3 of the License, or
rem (at your option) any later version.

rem This program is distributed in the hope that it will be useful,
rem but WITHOUT ANY WARRANTY; without even the implied warranty of
rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
rem GNU General Public License for more details.

rem You should have received a copy of the GNU General Public License
rem along with this program. If not, see <http://www.gnu.org/licenses/>.

rem ###############################################################################

rem This is the build script for creating an executable for the lambda-tube
rem application on a windows machine, which has PLT Scheme installed.
rem
rem Please ensure mzc.exe and 7z.exe are in PATH.

set LT_DIST_TOP_FOLDER=%cd%\dist
set DIST_START_TIME=%date:~10,4%_%date:~4,2%_%date:~7,2%_%time:~0,2%%time:~3,2%
set LT_DIST_FOLDER=%LT_DIST_TOP_FOLDER%\%DIST_START_TIME%\lambda-tube
set LT_DIST_ZIP=lambda-tube-%DIST_START_TIME%.zip

if "%1" == "installer" (
echo --lambda-tube stand-alone installer will be lambda-tube-0.2a-%DIST_START_TIME%-installer.exe
) else (
echo --lambda-tube stand-alone distribution archive will be %LT_DIST_ZIP%
)

mkdir %LT_DIST_FOLDER%

rem Compile the application into a MrEd executable
mzc --gui-exe lambda-tube ./src/lt-search.scm

rem Create a stand-alone distribution of the executable
mzc --exe-dir %LT_DIST_FOLDER% lambda-tube.exe

del lambda-tube.exe

rem Copy src, license, and build files to target
mkdir %LT_DIST_FOLDER%\src
copy src\*.scm %LT_DIST_FOLDER%\src

mkdir %LT_DIST_FOLDER%\i18n
copy i18n\languages %LT_DIST_FOLDER%\i18n
copy i18n\en_US %LT_DIST_FOLDER%\i18n
copy i18n\hi_IN %LT_DIST_FOLDER%\i18n

copy gpl.txt %LT_DIST_FOLDER%
copy build.sh %LT_DIST_FOLDER%
copy build.bat %LT_DIST_FOLDER%
copy MrEd-License.txt %LT_DIST_FOLDER%

if "%1" == "installer" (
goto INSTALLER
) else (
goto ZIP
)

:ZIP
rem zip
cd %LT_DIST_FOLDER%\..
7z a -tzip %LT_DIST_TOP_FOLDER%\%LT_DIST_ZIP% *
cd ..\..

echo --build complete--
goto END

:INSTALLER
copy lt-windows-installer-372.nsi %LT_DIST_FOLDER%\..
cd %LT_DIST_FOLDER%\..
makensis /DCURRENT_DIST_NAME=%DIST_START_TIME% lt-windows-installer-372.nsi
cd ..\..
goto END

:END
